<template>
  <div id='BScroll' class="wrapper" ref="bscroll">
    <div class="content">
      <slot></slot>
    </div>
  </div>
</template>

<script>
  import BScroll from 'better-scroll'
  export default {
    name: 'BScroll',
    data() {
      return {
        bs: null
      }
    },
    props: {
      probeType: {
        type: Number,
        default: 1
      },
      pullupload: {
        type: Boolean,
        default: true,
      },
      click: {
        type: Boolean,
        default: true
      }
    },
    mounted() {
      this.bs = new BScroll(this.$refs.bscroll, {
        probeType: this.probeType,
        pullUpLoad: this.pullupload,
        click: this.click
      });

      this.bs.on('scroll', position => {
        this.$emit('scroll', position)
      })
      this.bs.on('pullingUp', () => {
        this.$emit('pullingUp')
      })
    },
    components: {},
    methods: {
      scrollTo(x, y, time = 300) {
        this.bs.scrollTo(x, y, time)
      },
      finishpullup() {
        this.bs.finishPullUp()
      },
      refresh() {
        this.bs.refresh()
      },
      getscrollY() {
        return this.bs.y ? this.bs.y : 0
      }
    },
  }
</script>

<style scoped>
</style>